﻿<Page x:Class="WpfPostgresql.MagazinsPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"
	Title="MagazinsPage">

        <Grid>
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                <Button Content="Принять посылку" Command="{Binding AcceptCommand}" Name="AcceptBtn" Click="AcceptBtnClick" />
                <ComboBox Width="40" ItemsSource="{Binding Posilkas}" SelectedItem="{Binding SelectdPosilka}" >   
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding ID}"/>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </StackPanel>
            <ComboBox SelectionChanged="ComboBoxSelectionChanged" Text="Магазины" ItemsSource="{Binding Magazs}" SelectedItem="{Binding SelectedMagazs, Mode=TwoWay}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Border BorderBrush="Black" SnapsToDevicePixels="True" BorderThickness="1">
                                <TextBox Width="100" Text="{Binding Name}"/>
                            </Border>
                            <Border BorderBrush="Black" SnapsToDevicePixels="True" BorderThickness="1">
                                <TextBlock Width="150" Text="{Binding Addres}"/>
                            </Border>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
                </ComboBox>

            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Водитель: "/>
                <TextBlock Width="100" Text="{Binding VoditelPosilki.Name, Mode=TwoWay}"/>
                <TextBlock Text=" Кому: "/>
                <TextBlock Width="100" Text="{Binding MagazPosilki.Name}"/>
                <TextBlock Width="100" Text=" Адрес: "/>
                <TextBlock Width="100" Text="{Binding MagazPosilki.Addres}"/>
            </StackPanel>
            <Button Content="Refresh"  Click="ButtonClick"/>
                <TextBlock Text="Товар в магазине:"/>
            <ScrollViewer Height="200">
                <ListBox Name="TovarList" ItemsSource="{Binding TovarInMagazs}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <StackPanel Orientation="Horizontal">
                                    <Border BorderBrush="Black" SnapsToDevicePixels="True" BorderThickness="1">
                                        <TextBlock Width="100" Text="{Binding Name}"/>
                                    </Border>
                                    <Border BorderBrush="Black" SnapsToDevicePixels="True" BorderThickness="1">
                                        <TextBlock Width="50" Text="{Binding N}"/>
                                    </Border>
                                    <Button Content="-1"  Width="25" Command="{Binding ParentMagazVm.SubtractCommand}" CommandParameter="{Binding}"/>
                                    <Button Content="x" Width="25"  Command="{Binding ParentMagazVm.DelCommand}" CommandParameter="{Binding}" />
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </ScrollViewer>
            </StackPanel>
        </Grid>
</Page>
